package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqFinished;
import com.drug.mingkang.mapper.HqFinishedMapper;
import com.drug.mingkang.service.HqFinishedService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 成品采购(HqFinished)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:12
 */
@Service("hqFinishedService")
public class HqFinishedServiceImpl implements HqFinishedService {
    @Resource
    private HqFinishedMapper hqFinishedMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param finishId 主键
     * @return 实例对象
     */
    @Override
    public HqFinished queryById(String finishId) {
        return this.hqFinishedMapper.queryById(finishId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqFinished> queryAllByLimit(int offset, int limit) {
        return this.hqFinishedMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqFinished 实例对象
     * @return 实例对象
     */
    @Override
    public HqFinished insert(HqFinished hqFinished) {
        this.hqFinishedMapper.insert(hqFinished);
        return hqFinished;
    }

    /**
     * 修改数据
     *
     * @param hqFinished 实例对象
     * @return 实例对象
     */
    @Override
    public HqFinished update(HqFinished hqFinished) {
        this.hqFinishedMapper.update(hqFinished);
        return this.queryById(hqFinished.getFinishId());
    }

    /**
     * 通过主键删除数据
     *
     * @param finishId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String finishId) {
        return this.hqFinishedMapper.deleteById(finishId) > 0;
    }
}